package com.fa4j.third.base.service.impl;

import com.fa4j.third.base.config.ThirdConfig;
import com.fa4j.third.base.model.ThirdBizProps;
import com.fa4j.third.base.service.ThirdConfigService;
import lombok.RequiredArgsConstructor;

import java.util.Optional;

/**
 * 三方文件配置实现
 */
@RequiredArgsConstructor
public class ThirdFileConfigServiceImpl implements ThirdConfigService {

    private final ThirdConfig thirdConfig;

    @Override
    public Optional<ThirdBizProps> getBizProps(String bizCode) {
        return thirdConfig.getBizProps().stream().filter(prop -> bizCode.equals(prop.getBizCode())).findFirst();
    }

    @Override
    public boolean hasBizCode(String bizCode) {
        return thirdConfig.getBizProps().stream().anyMatch(b -> b.getBizCode().equals(bizCode));
    }
}
